<?php
/* @var $this PagesController */
/* @var $model Pages */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'pages-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'name'); ?>
		<?php echo $form->textField($model,'name'); ?>
		<?php echo $form->error($model,'name'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'slug'); ?>
		<?php //echo $form->textArea($model,'slug',array('rows'=>6, 'cols'=>50)); ?>
		<?php echo CHtml::activeTextField($model, 'slug', array('class' => 'content')); ?>
        <?php 
				
				Yii::app()->clientScript->registerScript('effect', '
				$("#Pages_name").keyup(function(){
        var Text = $(this).val();
        Text = Text.toLowerCase();
        var regExp = /\s+/g;
        Text = Text.replace(regExp,"-");
        $("#Pages_slug").val(Text);        
});
				', CClientScript::POS_READY);
				?> 
		<?php echo $form->error($model,'slug'); ?>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'title'); ?>
		<?php 
			echo $form->textField($model,'title'); ?>
		<?php echo $form->error($model,'title'); ?>
	</div>
	<?php Yii::import('application.modules.Category.models.*');
			//$category = CHtml::listData(Category::model()->findAll(), 'cat_id','category'); 
			/*$parent_cat = Category::model()->findAll('parent_cat = 0');
			//echo '<pre>'; print_r($parent_cat); exit;
			$data = array();
			foreach($parent_cat as $parent)
			{
					$sub_data = array();
					
					foreach($parent as $child)
					{
						//echo '<pre>'; print_r($child); exit;
							$sub_data[$child->parent_cat] = $child->category;
					}
					$data[$parent->category] = $sub_data;
			};*/?>
			
	<div class="row">
		<?php //echo $form->labelEx($model,'category'); ?>
		<?php //echo $form->textField($model,'category'); ?>
		<?php //echo'<pre>';print_r($roomtype);exit;
		//echo $form->dropDownlist($model,'category',$parent_cat); 
			 $parents = Category::model()->findAll('parent_cat = 0');
				$cm = new CommonMethods();

          $data = $cm->makeDropDown($parents);


          echo $form->labelEx($model,'category');

          echo $form->dropDownList($model,'category',  $data); ?>
		<?php echo $form->error($model,'category'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'content'); ?>
		<?php //echo $form->textArea($model,'content',array('rows'=>6, 'cols'=>50)); ?>
		<?php $this->widget('application.extensions.eckeditor.ECKEditor', array(
                'model'=>$model,
                'attribute'=>'content',
                )); ?>
		<?php echo $form->error($model,'content'); ?>
		
	</div>
	
	

	<div class="row">
		<?php echo $form->labelEx($model,'tag'); ?>
		<?php echo $form->textField($model,'tag',array('rows'=>6, 'cols'=>50)); ?>
		<?php echo $form->error($model,'tag'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'description'); ?>
		<?php //echo $form->textArea($model,'description',array('rows'=>6, 'cols'=>50)); ?>
		<?php $this->widget('application.extensions.eckeditor.ECKEditor', array(
                'model'=>$model,
                'attribute'=>'description',
                )); ?>
		<?php echo $form->error($model,'description'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'status'); ?>
		<?php echo $form->dropDownList($model,'status',array('Active','Inactive')); ?>
		<?php echo $form->error($model,'status'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->